<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>"><!-- jsp文件头和头部 -->
	<%@ include file="../../system/admin/top.jsp"%> 
	</head>
<body>

<form action="employee/list.do" method="post" name="Form" id="Form">
	<p class="operate">
		<c:if test="${QX.add == 1 }">
			<a class="create Operate" title="新增" href="<%=basePath%>employee/goAdd.do" target="opFrame">新增</a>
		</c:if>
		<c:if test="${QX.del == 1 }">
		<a class="delete" onclick="makeAll('确定要删除选中的数据吗?');" title="批量删除" >批量删除</a>
		</c:if>
    </p>
	<table>
		<colgroup>
            <col width="2%">
            <col width="3%">
            <col width="5%">
            <col width="3%">
            <col width="8%">
            <col width="8%">
            <col width="9%">
            <col width="5%">
            <col width="8%">
            <col width="8%">
            <col width="5%">
            <col width="8%">
            <col width="13%">
        </colgroup>
		<thead>
			<tr>
				<th><input type="checkbox" id="zcheckbox"></th>
				<th class="center">序号</th>
				<th class="center">姓名</th>
				<th class="center">性别</th>
				<th class="center">员工编号</th>
				<th class="center">登录账号</th>
				<th class="center">手机号</th>
				<th class="center">学历</th>
				<th class="center">职称</th>
				<th class="center">所属部门</th>
				<th class="center">员工状态</th>
				<th class="center">入职时间</th>
				<th class="center">操作</th>
			</tr>
		</thead>
		<tbody>
			
		<!-- 开始循环 -->	
		<c:choose>
			<c:when test="${not empty varList}">
				<c:if test="${QX.cha == 1 }">
				<c:forEach items="${varList}" var="var" varStatus="vs">
					<tr>
						<td class='center' style="width: 30px;">
							<label><input type='checkbox' name='ids' value="${var.base_id}" /><span class="lbl"></span></label>
						</td>
						<td class='center' style="width: 30px;">${vs.index+1}</td>
						<td><a href="<%=basePath%>employee/goDetail.do?base_id=${var.base_id}">${var.base_name}</a></td>
						<td>
							<c:if test="${var.base_sex == '0'}">男</c:if>
						    <c:if test="${var.base_sex == '1'}">女</c:if>
						</td>
						<td>${var.work_serial_number}</td>
						<td>${var.USERNAME}</td>
						<td>${var.base_phone}</td>
						<td>
							<c:if test="${var.base_education_background == '0'}">小学</c:if>
						    <c:if test="${var.base_education_background == '1'}">初中</c:if>
						    <c:if test="${var.base_education_background == '2'}">中专</c:if>
						    <c:if test="${var.base_education_background == '3'}">高中</c:if>
						    <c:if test="${var.base_education_background == '4'}">大专</c:if>
						    <c:if test="${var.base_education_background == '5'}">本科</c:if>
						    <c:if test="${var.base_education_background == '6'}">硕士研究生</c:if>
						    <c:if test="${var.base_education_background == '7'}">博士研究生</c:if>
						</td>
						<td>${var.work_position}</td>
						<td>
							<c:forEach items="${deptList}" var="department">
								<c:if test="${var.department_id==department.departmentId}">${department.departmentName }</c:if>
							</c:forEach>
						</td>
						<td>
							<c:if test="${var.work_status == '0'}">试用</c:if>
							<c:if test="${var.work_status == '1'}">在岗</c:if>
							<c:if test="${var.work_status == '2'}">待岗</c:if>
							<c:if test="${var.work_status == '3'}">见习</c:if>
							<c:if test="${var.work_status == '4'}">离职</c:if>
							<c:if test="${var.work_status == '5'}">退休</c:if>
						</td>
						<td>
							<fmt:formatDate value="${var.work_entrytime}" pattern="yyyy-MM-dd"/>
						</td>
						<td>
					    <p class="operate">
					    	<c:if test="${QX.edit != 1 && QX.del != 1 }">
							</c:if>
					    	<c:if test="${QX.edit == 1 }">
								<c:if test="${pd.rank==0 && var.base_record_status==0}">
									<a title="编辑" href="<%=basePath%>employee/goEdit.do?base_id=${var.base_id}" class="revise Operate" target="opFrame">修改</a>
								</c:if>
								<c:if test="${pd.rank==2}">
									<a title="编辑" href="<%=basePath%>employee/goEdit.do?base_id=${var.base_id}" class="revise Operate" target="opFrame">修改</a>
								</c:if>
							</c:if>
							<c:if test="${QX.edit == 1 }">
								<c:if test="${pd.rank==2}">
								<a title="离职" onclick="updateWorkStatus('${var.base_id}');" class="revise Operate" target="opFrame">离职</a>
								</c:if>
							</c:if>
							<c:if test="${QX.edit == 1 }">
								<c:if test="${pd.rank==2}">
								<a title="归档" onclick="updateWorkStatus('${var.base_id}');" class="revise Operate" target="opFrame">归档</a>
								</c:if>
							</c:if>
							
							<c:if test="${QX.del == 1 }">
								<a title="删除" onclick="del('${var.base_id}');" class="delete">删除</a>
							</c:if>
	                    </p>
						</td>
					</tr>
				</c:forEach>
				</c:if>
				<c:if test="${QX.cha == 0 }">
					<tr>
						<td colspan="100" class="center">您无权查看</td>
					</tr>
				</c:if>
			</c:when>
			<c:otherwise>
				<tr class="main_info">
					<td colspan="100" class="center" >没有相关数据</td>
				</tr>
			</c:otherwise>
		</c:choose>
			
		
		</tbody>
	</table>
	<!--分页器-->
    <div class="branchPage">${page.pageStr}</div>
</form>
</body>
<script type="text/javascript">
	
	//检索
	function search(){
		top.jzts();
		$("#Form").submit();
	}
	
	//新增
	function add(){
		 top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="新增";
		 diag.URL = '<%=basePath%>employee/goAdd.do';
		 diag.Width = 380;
		 diag.Height = 355;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				 if('${page.currentPage}' == '0'){
					 top.jzts();
					 setTimeout("self.location=self.location",100);
				 }else{
					 nextPage(${page.currentPage});
				 }
			}
			diag.close();
		 };
		 diag.show();
	}
	
	//离职
	function updateWorkStatus(Id){
		bootbox.confirm("确定离职该员工吗?", function(result) {
			if(result) {
				top.jzts();
				var url = "<%=basePath%>employee/updateWorkStatus.do?base_id="+Id;
				$.get(url,function(data){
					nextPage(${page.currentPage});
				});
			}
		});
	}
	
	//归档
	function goUpdateRecord(Id){
		top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="归档";
		 diag.URL ="<%=basePath%>employee/goUpdateRecord.do?base_id="+Id;
		 diag.Width = 380;
		 diag.Height = 355;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				 if('${page.currentPage}' == '0'){
					 top.jzts();
					 setTimeout("self.location=self.location",100);
				 }else{
					 nextPage(${page.currentPage});
				 }
			}
			diag.close();
		 };
		 diag.show();
	}
	
	//删除
	function del(Id){
		var message = confirm('确定要删除吗?');
		if(message) {
			var url = "<%=basePath%>employee/delete.do?base_id="+Id;
			$.get(url,function(data){
				if(data == "success"){
					alert("删除成功！");
					//刷新列表页面
					var n = $(".label-ul li.now",window.parent.document).index();
					var id = $(".content-box>iframe",window.parent.document).eq(n).attr('id');
					$("#"+id,parent.document.body).attr("src","<%=basePath%>employee/list.do");
				}
			});
		}
	}
	
	//修改
	function edit(Id){
		 top.jzts();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="编辑";
		 diag.URL = '<%=basePath%>personnelemployee/goEdit.do?PERSONNELEMPLOYEE_ID='+Id;
		 diag.Width = 450;
		 diag.Height = 355;
		 diag.CancelEvent = function(){ //关闭事件
			 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				 nextPage(${page.currentPage});
			}
			diag.close();
		 };
		 diag.show();
	}
	
	$(function() {
		//复选框
		$('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
				
		});
		
	});
	
	
	//批量操作
	function makeAll(msg){
		bootbox.confirm(msg, function(result) {
			if(result) {
				var str = '';
				for(var i=0;i < document.getElementsByName('ids').length;i++)
				{
					  if(document.getElementsByName('ids')[i].checked){
					  	if(str=='') str += document.getElementsByName('ids')[i].value;
					  	else str += ',' + document.getElementsByName('ids')[i].value;
					  }
				}
				if(str==''){
					bootbox.dialog("您没有选择任何内容!", 
						[
						  {
							"label" : "关闭",
							"class" : "btn-small btn-success",
							"callback": function() {
								//Example.show("great success");
								}
							}
						 ]
					);
					
					$("#zcheckbox").tips({
						side:3,
			            msg:'点这里全选',
			            bg:'#AE81FF',
			            time:8
			        });
					
					return;
				}else{
					if(msg == '确定要删除选中的数据吗?'){
						top.jzts();
						$.ajax({
							type: "POST",
							url: '<%=basePath%>personnelemployee/deleteAll.do?tm='+new Date().getTime(),
					    	data: {DATA_IDS:str},
							dataType:'json',
							//beforeSend: validateData,
							cache: false,
							success: function(data){
								 $.each(data.list, function(i, list){
										nextPage(${page.currentPage});
								 });
							}
						});
					}
				}
			}
		});
	}

	//导出excel
	function toExcel(){
		window.location.href='<%=basePath%>personnelemployee/excel.do';
	}
</script>

</html>

